import { useDispatch } from "react-redux";
import { Button } from "antd-mobile";
import { decrement } from "../../store/features/count";
import { useAppSelector } from "../../store/hook";
import { useEffect } from "react";
import { categoryGet } from "../../api/course";
import { changeMovieList } from "../../store/features/movie";
export interface ICompBProps {}

export default function CompB(props: ICompBProps) {
  const { count, course } = useAppSelector((state) => state);
  const dispatch = useDispatch();
  useEffect(() => {
    categoryGet().then((res) => {
      dispatch(changeMovieList(res.data.results));
    });
  }, []);
  return (
    <div>
      <h1>B组件,{count.num}</h1>
      <Button
        color="primary"
        onClick={() => {
          dispatch(decrement());
        }}
      >
        -
      </Button>
      {course.list.map((item: any) => {
        return <div>{item.name}</div>;
      })}
    </div>
  );
}
